<%@page import="org.proddevplm.dao.data.conceptSelection.PughAnalysis"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.util.List"%>

<script>
	var ahpResults = [];
	

<%
	float[] ahpResults = (float[])session.getAttribute("ahpResults");
	for (int i=0; i<ahpResults.length; i++) {
		%>ahpResults[<%=i%>]=<%=ahpResults[i]%>;<%
	}
%>

	$(function(){
		
		$("#ahpResultsTable").tablesorter({
			headers:{
				1:{sorter: false}
			},
			sortList:[[2,1]]
		})
		$( ".progressbar" ).progressbar();
	});
	
	function show(index, value){
		
		var value = value*100;
		var id = "td_"+index;
		
		$('#'+id).progressbar("option", "value", value);
	}
		
	for(var i=0; i<ahpResults.length; i++){
		show(i+' ',ahpResults[i]);
	}
</script>

<%
	PughAnalysis currentPugh = (PughAnalysis)session.getAttribute("currentPugh");	
	String criteriaList = currentPugh.getCriteria();
	String[] criterion = criteriaList.split("~");
%>

	<table class="tablesorter" id="ahpResultsTable" rules="rows" frame="hsides" bordercolor="#DBDBDB" style="font-size:small; width:100%">
		<thead>
			<tr>
				<th >Item</th>
				<th >Importance</th>
				<th >&nbsp</th>
			</tr>
		</thead>
		
		<%if(ahpResults!=null){
			for(int i=0; i<ahpResults.length; i++){
				Float value = ahpResults[i]*100;
				DecimalFormat dFormat = new DecimalFormat("0.00");
				String shownVal = dFormat.format(value)+"%";
			%>
			<tr>
				<td><%=criterion[i] %></td>
				<td class="progressbar" id="td_<%=i %>" style="width:auto; height:15px; border:0px" ></td>
				<td style="width:50px"><%=shownVal%></td>
			</tr>
		<%}} %>
	</table>